package com.timeriver.web;

import com.timeriver.domain.ResponseObj;
import com.timeriver.service.TaskService;
import com.timeriver.utils.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Spark/Flink任务执行
 */
@RestController
@RequestMapping("/task")
public class TaskController {

    @Autowired
    private TaskService service;

    @PostMapping("/runTask")
    public ResponseObj runTask() {
        try {
            service.runTask();
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseUtil.error(e.getMessage());
        }
        return ResponseUtil.success("执行成功", null);
    }
}
